home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 February / macformat-047.iso / Demos / Simpsons Cartoon Studio™ Demo / Simpdata / simpmain / 00008_applicationManager parent.ls < prev    next >
Encoding:
Text File  |  1996-09-06  |  8.7 KB  |  283 lines

  1. property currentSoundLevel, placeHolderCast, totalMemory, theBrainCastNumList
  2. global usersColorDepth, leftPanelSpr, soundStatusFieldSpr, loopStatusFieldSpr, listMgr, fileMgr, dirtyFlag, PCflag
  3.  
  4. on birth me
  5.   set currentSoundLevel to 3
  6.   set the volume of sound 1 to 32 * currentSoundLevel
  7.   set the volume of sound 2 to 32 * currentSoundLevel
  8.   set theBrainCastNumList to [151, 152, 153, 154, 155, 156, 157, 158, 159, 160]
  9.   formatTextFields(me)
  10.   initializeTextFields(me)
  11.   set placeHolderCast to the number of cast "placeholder cast"
  12.   set totalMemory to the freeBytes
  13.   return me
  14. end
  15.  
  16. on newCartoon me
  17.   if dirtyFlag then
  18.     set theMessage to "Do you want to save your changes before starting a new cartoon?"
  19.     set theAlertBoxType to #dontsave_cancel_save
  20.     showTheAlertBox(theMessage, theAlertBoxType, "reset(appMgr)", "nothing", "doSaveThenNextAction(fileMgr, #new)")
  21.   else
  22.     set theMessage to "Are you sure you want to start a new cartoon?"
  23.     set theAlertBoxType to #cancel_ok
  24.     showTheAlertBox(theMessage, theAlertBoxType, "nothing", "nothing", "reset(appMgr)")
  25.   end if
  26. end
  27.  
  28. on quitToolbox me
  29.   if dirtyFlag then
  30.     set theMessage to "Do you want to save your changes before quitting?"
  31.     set theAlertBoxType to #dontsave_cancel_save
  32.     showTheAlertBox(theMessage, theAlertBoxType, "justQuit(appMgr)", "nothing", "doSaveThenNextAction(fileMgr, #quit)")
  33.   else
  34.     set theMessage to "Are you sure you want to quit?"
  35.     set theAlertBoxType to #cancel_ok
  36.     showTheAlertBox(theMessage, theAlertBoxType, "nothing", "nothing", "justQuit(appMgr)")
  37.   end if
  38. end
  39.  
  40. on justQUit
  41.   repeat with i = 2 to 16
  42.     set the locH of sprite i to -1000
  43.   end repeat
  44.   repeat with i = 36 to 48
  45.     set the locH of sprite i to -1000
  46.   end repeat
  47.   updateStage()
  48.   startTimer()
  49.   set the castNum of sprite 1 to the number of cast "credits1"
  50.   set the loc of sprite 1 to point(313, 218)
  51.   updateStage()
  52.   repeat while (the timer < 7200) and the mouseUp
  53.   end repeat
  54.   if PCflag then
  55.     repeat with i = 1 to 48
  56.       set the locH of sprite i to -1000
  57.     end repeat
  58.     updateStage()
  59.     repeat with i = 1 to 48
  60.       puppetSprite(i, 0)
  61.     end repeat
  62.     go("PCQUIT")
  63.   else
  64.     set the colorDepth to usersColorDepth
  65.     startTimer()
  66.     quit()
  67.   end if
  68. end
  69.  
  70. on showCredits me
  71.   set songNumber to random(the number of lines in field "LOOdata")
  72.   set songRecord to value(line songNumber of field "LOOdata")
  73.   set theSongCastNum to getAt(songRecord, 3)
  74.   puppetSound(2, theSongCastNum)
  75.   set oldBgd to the castNum of sprite 1
  76.   set oldLocOfSpr1 to the loc of sprite 1
  77.   set oldLocHofSpr2 to the locH of sprite 2
  78.   set oldLocHofSpr16 to the locH of sprite 16
  79.   set the locH of sprite 2 to -1000
  80.   set the locH of sprite 16 to -1000
  81.   repeat with theSprite = 3 to 14
  82.     set the blend of sprite theSprite to 30
  83.   end repeat
  84.   startTimer()
  85.   set the castNum of sprite 1 to the number of cast "credits1"
  86.   set the loc of sprite 1 to point(313, 218)
  87.   updateStage()
  88.   puppetTransition(51)
  89.   repeat while (the timer < 600) and the mouseUp
  90.     if not soundBusy(2) then
  91.       puppetSound(2, theSongCastNum)
  92.     end if
  93.   end repeat
  94.   startTimer()
  95.   set the castNum of sprite 1 to the number of cast "credits2"
  96.   set the loc of sprite 1 to point(313, 218)
  97.   updateStage()
  98.   puppetTransition(51)
  99.   repeat while (the timer < 600) and the mouseUp
  100.     if not soundBusy(2) then
  101.       puppetSound(2, theSongCastNum)
  102.     end if
  103.   end repeat
  104.   startTimer()
  105.   set the castNum of sprite 1 to the number of cast "credits3"
  106.   set the loc of sprite 1 to point(313, 218)
  107.   updateStage()
  108.   puppetTransition(51)
  109.   repeat while (the timer < 600) and the mouseUp
  110.     if not soundBusy(2) then
  111.       puppetSound(2, theSongCastNum)
  112.     end if
  113.   end repeat
  114.   startTimer()
  115.   set the castNum of sprite 1 to the number of cast "credits4"
  116.   set the loc of sprite 1 to point(313, 218)
  117.   updateStage()
  118.   puppetTransition(51)
  119.   repeat while (the timer < 600) and the mouseUp
  120.     if not soundBusy(2) then
  121.       puppetSound(2, theSongCastNum)
  122.     end if
  123.   end repeat
  124.   startTimer()
  125.   set the castNum of sprite 1 to the number of cast "credits5"
  126.   set the loc of sprite 1 to point(313, 218)
  127.   updateStage()
  128.   puppetTransition(51)
  129.   repeat while (the timer < 600) and the mouseUp
  130.     if not soundBusy(2) then
  131.       puppetSound(2, theSongCastNum)
  132.     end if
  133.   end repeat
  134.   set the locH of sprite 2 to oldLocHofSpr2
  135.   set the locH of sprite 16 to oldLocHofSpr16
  136.   repeat with theSprite = 3 to 14
  137.     set the blend of sprite theSprite to 100
  138.   end repeat
  139.   set the castNum of sprite 1 to oldBgd
  140.   set the loc of sprite 1 to oldLocOfSpr1
  141.   set oldVolume to the volume of sound 2
  142.   repeat while the volume of sound 2 > 0
  143.     startTimer()
  144.     set the volume of sound 2 to the volume of sound 2 - 8
  145.     repeat while the timer < 6
  146.     end repeat
  147.   end repeat
  148.   puppetSound(2, 0)
  149.   set the volume of sound 2 to oldVolume
  150.   updateStage()
  151. end
  152.  
  153. on reset me
  154.   cursor(4)
  155.   repeat with i = 2 to 14
  156.     set the castNum of sprite i to placeHolderCast
  157.     set the locH of sprite i to -1000
  158.   end repeat
  159.   set the castNum of sprite 16 to placeHolderCast
  160.   set the locH of sprite 16 to -1000
  161.   clearToonDataFileName(fileMgr)
  162.   setCurrentCartoonName(fileMgr, "Untitled")
  163.   setCurrentCartoonCredits(fileMgr, EMPTY)
  164.   resetKrusty(playbackMgr)
  165.   clear(layerMgr)
  166.   reset(listMgr)
  167.   update(stackMgr)
  168.   initializeTextFields(me)
  169.   unLoadCast()
  170.   updateTheBrain(me)
  171.   cursor(-1)
  172.   set dirtyFlag to 0
  173.   updateStage()
  174. end
  175.  
  176. on updateFileNameField me
  177.   set the text of field "fileNameField" to getCurrentCartoonName(fileMgr)
  178. end
  179.  
  180. on checkMemory me
  181.   if the optionDown then
  182.     clearMemory(me)
  183.   else
  184.     set the text of field "fileNameField" to the freeBytes / 1024 & "K free"
  185.     cursor(-1)
  186.     repeat while the mouseUp
  187.     end repeat
  188.     updateFileNameField(me)
  189.   end if
  190. end
  191.  
  192. on clearMemory me
  193.   unLoadCast()
  194.   set the text of field "fileNameField" to "clearing memory‚Ķ"
  195.   updateStage()
  196.   updateFileNameField(me)
  197.   updateTheBrain(me)
  198. end
  199.  
  200. on updateTheBrain me
  201.   set usedMemory to totalMemory - the freeBytes
  202.   set percentageFull to integer(usedMemory * 100 / totalMemory)
  203.   set percentageFull to percentageFull / 10
  204.   if percentageFull > 0 then
  205.     set oldPanel to the castNum of sprite leftPanelSpr
  206.     set newPanel to getAt(theBrainCastNumList, percentageFull)
  207.     if newPanel <> oldPanel then
  208.       set the castNum of sprite leftPanelSpr to newPanel
  209.       unLoadCast(oldPanel)
  210.     end if
  211.   else
  212.     set oldPanel to the castNum of sprite leftPanelSpr
  213.     set newPanel to the number of cast "left panel base"
  214.     if newPanel <> oldPanel then
  215.       set the castNum of sprite leftPanelSpr to newPanel
  216.       unLoadCast(oldPanel)
  217.     end if
  218.   end if
  219. end
  220.  
  221. on changeVolume me, volumePosition
  222.   set currentSoundLevel to volumePosition
  223.   set the volume of sound 1 to 32 * currentSoundLevel
  224.   set the volume of sound 2 to 32 * currentSoundLevel
  225. end
  226.  
  227. on getCurrentSoundLevel me
  228.   return currentSoundLevel
  229. end
  230.  
  231. on formatTextFields me
  232.   if PCflag then
  233.     set the textFont of field "filenamefield" to "Arial"
  234.     set the textSize of field "filenamefield" to 10
  235.     set the textStyle of field "filenamefield" to "bold"
  236.     set the textFont of cast "loopstatusfield" to "Arial"
  237.     set the textSize of cast "loopstatusfield" to 9
  238.     set the textStyle of cast "loopstatusfield" to "plain"
  239.     set the textFont of cast "soundstatusfield" to "Arial"
  240.     set the textSize of cast "soundstatusfield" to 9
  241.     set the textStyle of cast "soundstatusfield" to "plain"
  242.   else
  243.     set the textFont of field "filenamefield" to "Geneva"
  244.     set the textSize of field "filenamefield" to 10
  245.     set the textStyle of field "filenamefield" to "bold"
  246.     set the textFont of cast "loopstatusfield" to "Geneva"
  247.     set the textSize of cast "loopstatusfield" to 9
  248.     set the textStyle of cast "loopstatusfield" to "plain"
  249.     set the textFont of cast "soundstatusfield" to "Geneva"
  250.     set the textSize of cast "soundstatusfield" to 9
  251.     set the textStyle of cast "soundstatusfield" to "plain"
  252.   end if
  253. end
  254.  
  255. on initializeTextFields me
  256.   set the text of field "fileNameField" to "Untitled"
  257.   set the text of field "loopstatusfield" to EMPTY
  258.   set the text of field "soundstatusfield" to EMPTY
  259.   set the loc of sprite loopStatusFieldSpr to point(147, 403)
  260.   set the loc of sprite soundStatusFieldSpr to point(391, 403)
  261.   updateStage()
  262. end
  263.  
  264. on hiliteSoundFXField me
  265.   set the foreColor of cast "soundStatusField" to 39
  266.   set the backColor of cast "soundStatusField" to 255
  267.   updateStage()
  268. end
  269.  
  270. on hiliteSoundLoopField me
  271.   set the foreColor of cast "loopStatusField" to 39
  272.   set the backColor of cast "loopStatusField" to 255
  273.   updateStage()
  274. end
  275.  
  276. on hideFieldHiliterSpr me
  277.   set the foreColor of cast "soundStatusField" to 255
  278.   set the backColor of cast "soundStatusField" to 39
  279.   set the foreColor of cast "loopStatusField" to 255
  280.   set the backColor of cast "loopStatusField" to 39
  281.   updateStage()
  282. end
  283.